package net.blank.world.world2D.business.unit
{
	import net.blank.functionUtl.FunctionBinder;
	import net.blank.world.world2D.template.unit.Inorganic_tmp;
	
	/**
	 * 无机物
	 * @author blank
	 * 
	 */
	public class Inorganic extends AbstractUnit
	{
		/**
		 * 可穿越状态修正值(null表示清除修正,即使用模板的值)
		 */
		private var _correctIsPassable:Object;
		
		/**
		 * <font color=#0000ff>[可绑定]</font>可穿越状态修正值(null表示清除修正,即使用模板的值)
		 * @param value
		 * 
		 */
		public function setCorrectIsPassable(value:Object):void{
			if(value != _correctIsPassable){
				_correctIsPassable=value;
				
				if(_correctIsPassable == null){
					super.setIsPassable((getTemplate() as Inorganic_tmp).baseIsPassable);
				}else{
					super.setIsPassable(_correctIsPassable);
				}
				
				FunctionBinder.execCallbackFun(setCorrectIsPassable,[this]);
			}
		}
		
		/**
		 * 可穿越状态修正值
		 * @return 
		 * 
		 */
		public function getCorrectIsPassable():Object{
			return _correctIsPassable;
		}
		
		/**
		 * 穿越代价修正值
		 * @return 
		 * 
		 */
		private var _correctPassCost:int;
		
		/**
		 * <font color=#0000ff>[可绑定]</font>穿越代价修正值
		 * @param value
		 * 
		 */
		public function setCorrectPassCost(value:int):void{
			if(value != _correctPassCost){
				_correctPassCost=value;
				
				super.setPassCost((getTemplate() as Inorganic_tmp).basePassCost+_correctPassCost);
				
				FunctionBinder.execCallbackFun(setCorrectPassCost,[this]);
			}
		}
		
		override public function setIsPassable(value:Boolean):void{
			throw new Error("请使用 setCorrectIsPassable 设置可穿越状态");
		}
		
		override public function setPassCost(value:int):void{
			throw new Error("请使用 setCorrectPassCost 设置穿越代价");
		}
		
		/**
		 * 穿越代价修正值
		 * @return 
		 * 
		 */
		public function getCorrectPassCost():int{
			return _correctPassCost;
		}
		
		/**
		 * 增加血量
		 */
		private var _addHealthPoint:int;
		
		/**
		 * <font color=#0000ff>[可绑定]</font>增加的血量
		 * @param value
		 * 
		 */
		public function setAddHealthPoint(value:int):void{
			if(value != _addHealthPoint){
				_addHealthPoint=value;
				
				FunctionBinder.execCallbackFun(setAddHealthPoint,[this]);
			}
		}
		/**
		 * 增加血量
		 * @return 
		 * 
		 */
		public function getAddHealthPoint():int{
			return _addHealthPoint;
		}
		
		/**
		 * 血量
		 * @return 
		 * 
		 */
		public function getHealthPoint():int{
			return (getTemplate() as Inorganic_tmp).baseHealthPoint+_addHealthPoint;
		}
		
		/**
		 * 无机物
		 * @param template
		 * 
		 */
		public function Inorganic(template:Inorganic_tmp){
			super(template);
			
			init();
		}
		
		/**
		 * 初始化
		 * 
		 */
		protected function init():void{
			var i_t:Inorganic_tmp=getTemplate() as Inorganic_tmp;
			
			super.setIsPassable(i_t.baseIsPassable);
			super.setPassCost(i_t.basePassCost);
		}
		
		override public function reset():void{
			super.reset();
			
			FunctionBinder.clearBindingFuns(setCorrectIsPassable,setCorrectPassCost,setAddHealthPoint);
			
			_correctIsPassable=null;
			_correctPassCost=0;
			_addHealthPoint=0;
		}
		
		override public function destroy():void{
			super.destroy();
			
			FunctionBinder.clearBindingFuns(setCorrectIsPassable,setCorrectPassCost,setAddHealthPoint);
		}
		
		override protected function copyProperties(obj:AbstractUnit):void{
			super.copyProperties(obj);
			
			var t:Inorganic=obj as Inorganic;
			
			t._correctIsPassable=_correctIsPassable;
			t._correctPassCost=_correctPassCost;
			t._addHealthPoint=_addHealthPoint;
		}
		
		override public function clone():*{
			var obj:Inorganic=new Inorganic(getTemplate() as Inorganic_tmp);
			copyProperties(obj);
			
			return obj;
		}
	}
}